import { assign, map } from 'lodash'
import { get, getForFile, post, postForFile, request } from './service'

const modules = import.meta.globEager('./modules/*.js')
const apis = {}
Object.keys(modules).forEach(key => {
  const newKey = key.substr(10, key.lastIndexOf('.') - 10)
  apis[newKey] = assign({}, ...map(modules[key], api => api({
    get,
    post,
    getForFile,
    postForFile,
    request
  })))
})
export default apis
